/*     */ package com.qmsk.business.area.area.controller;
/*     */ 
/*     */ import com.qmsk.business.area.area.dao.AreaDAO;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/area"})
/*     */ public class AreaController
/*     */ {
/*  28 */   private static final Logger logger = Logger.getLogger(AreaController.class);
/*     */ 
/*     */   @Autowired
/*     */   private AreaDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/all/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAll(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  47 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  49 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(nPageIdx, nPageSize);
/*  50 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  52 */       logger.error(e);
/*  53 */       ResponseUtils.setErrorMsgResponse(
/*  54 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*  70 */     String sGsonInData = request.getParameter("data");
/*     */     try {
/*  72 */       int nResult = this.dao.insertJsonOneRow(sGsonInData);
/*  73 */       ResponseUtils.setSqlResultResponse(nResult, 
/*  74 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/*  75 */         response);
/*  76 */       DbConnection.commit();
/*     */     } catch (Exception e) {
/*  78 */       DbConnection.rollback();
/*  79 */       logger.error(e);
/*  80 */       ResponseUtils.setErrorMsgResponse(
/*  81 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/*  82 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*  98 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 100 */       String[] strParams = id.split(",");
/* 101 */       int nResult = this.dao.deleteParams(strParams);
/* 102 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 103 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 104 */         response);
/* 105 */       DbConnection.commit();
/*     */     } catch (Exception e) {
/* 107 */       DbConnection.rollback();
/* 108 */       logger.error(e);
/* 109 */       ResponseUtils.setErrorMsgResponse(
/* 110 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 111 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 127 */     String id = request.getParameter("id");
/* 128 */     String sGsonInData = request.getParameter("data");
/*     */     try {
/* 130 */       GsonHeadOneRow g = GsonHeadOneRow.jsonStrToObject(sGsonInData);
/* 131 */       if (g == null) {
/* 132 */         ResponseUtils.setErrorMsgResponse(
/* 133 */           RequestUtils.getReadJsonDataErrorMessage(request), 
/* 134 */           response);
/*     */       } else {
/* 136 */         int nResult = this.dao.updateJsonOneRow(g, id);
/* 137 */         ResponseUtils.setSqlResultResponse(nResult, 
/* 138 */           RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 139 */           response);
/*     */       }
/* 141 */       DbConnection.commit();
/*     */     } catch (Exception e) {
/* 143 */       DbConnection.rollback();
/* 144 */       logger.error(e);
/* 145 */       ResponseUtils.setErrorMsgResponse(
/* 146 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 147 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.area.area.controller.AreaController
 * JD-Core Version:    0.5.3
 */